import request from '@/utils/request';

/**
 * 获取大屏分类
 */
export function getKanbanDir() {
    return request({
        url: 'screen/group',
        method: 'post',
    })
}
/**
 * 创建或修改分类
 */
export function createFolder(data) {
    return request({
        url: 'screen/groupedit',
        method: 'post',
        data,
    })
}

/**
 * 创建或修改分类
 */
export function removeGroup(data) {
    return request({
        url: 'screen/removeGroup',
        method: 'post',
        data,
    })
}
/**
 * 获取大屏列表
 */
export function getDashboardList(data) {
  return request({
    url: 'screen/index',
    method: 'post',
    data: {
      ...data
    },
  })
}
/**
 * 删除大屏
 */
export function removeKanban(id) {
  return request({
    url: 'screen/del',
    method: 'post',
    data: { id },
  })
}
/**
 * 发布已保存的看板
 */
export function publishKanban(id) {
  return request({
    url: '/analysis/kanban/publish',
    method: 'post',
    data: { id },
  })
}

/**
 * 获取所有发布过的看板
 */
export function getPublishList(name) {
  return request({
    url: '/analysis/kanban/publish/list',
    method: 'post',
    data: { name },
  })
}

/**
 * 保存大屏
 * id: 当id为空时，创建看板，当id不为空时，更新看板
 * name: 大屏名称
 */
export function saveKanban({id, name, category_id, status, layout, components}) {
    return request({
        url: 'screen/create',
        method: 'post',
        data: {id, name, category_id, status, layout, components},
    })
}

/**
 * 载入大屏模板
 */
export function loadKanban(id) {
    return request({
        url: 'screen/detail',
        method: 'post',
        data: {id},
    })
}

/**
 * 查询数据集
 */
export function getModelDataById({ modelId, x, y, filters }) {
    return request({
        url: 'cube/componentgetdata',
        method: 'post',
        data: { modelId, x, y, filters },
    })
}
